import { createStore, useStore as _useStore } from 'vuex'
import { AccountState } from './account'

import global, { GlobalState } from './global'

import mockTest, { MockTestState } from './mockTest'

import account from './account'
import { App } from 'vue'
import { AugmentedStore } from './types'

export interface State {
  global: GlobalState
  mockTest: MockTestState
  account: AccountState
}

const store = createStore({
  modules: {
    global,
    mockTest,
    account,
  },
}) as AugmentedStore

export function useStore() {
  return _useStore() as AugmentedStore
}

// 配置 store
export function setupStore(app: App<Element>) {
  app.use(store)
}

export default store
